package com.beta.em.order;

import java.util.Objects;

/**
 * Created by lichao on 2016/11/24.
 */
public enum OrderStatus {

    INIT("-", "初始状态"),
    PENDING("pending", "待审核"),
    FREIGHT_PAYING("freight_paying", "付运费中"),
    PAYING("paying", "付款中"),
    ASSIGNING("assigning", "待出货"),
    DELIVERING("delivering", "已发货"),
    CONFIRMED("confirmed", "已收货"),
    COMPLETED("completed", "已完成"),
    SETTLED("settled", "已清算"),
    CANCELED("canceled", "已取消"),
    EXPIRED("expired","已过期");

    private String value;
    private String cnValue;

    OrderStatus(String value, String cnValue) {
        this.value = value;
        this.cnValue = cnValue;
    }

    public String getCnValue() {
        return cnValue;
    }

    public String getValue() {
        return value;
    }

    public static OrderStatus getOrderStatus(String value) {
        for (OrderStatus orderStatus: values()) {
            if (orderStatus.getValue().equals(value)) {
                return orderStatus;
            }
        }
        return null;
    }

    public static String getCnValue(String value) {
        OrderStatus orderStatus = getOrderStatus(value);
        if (Objects.nonNull(orderStatus)) {
            return orderStatus.getCnValue();
        } else {
            return "";
        }
    }

}